﻿using MiniFox.Components;
using DingTalk.Corp.Auth.Models;

namespace DingTalk.Corp.Auth.Services
{
    /// <summary>
    /// 
    /// </summary>
    [AutoRegister, SpareComponent(typeof(DingTalkAgentAuthService))]
    public interface IDingTalkAgentAuthService
    {
        /// <summary>
        /// 
        /// </summary>
        Uri OpenAuthUri { get; }
        /// <summary>
        /// 
        /// </summary>
        Uri QrAuthUri { get; }
        /// <summary>
        /// 
        /// </summary>
        Uri SessionUri { get; }
        /// <summary>
        /// 
        /// </summary>
        Uri UserTokenUri { get; }
        /// <summary>
        /// 
        /// </summary>
        Uri UserInfoUri { get; }
        /// <summary>
        /// 
        /// </summary>
        Uri GetUserIdUri { get; }

        #region create uri
        /// <summary>
        /// 
        /// </summary>
        /// <param name="redirectUri"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        string CreateRedirectUri(string redirectUri, string state);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="redirectUri"></param>
        /// <param name="state"></param>
        /// <param name="authMode"></param>
        /// <returns></returns>
        string CreateRedirectUri(string redirectUri, string state, AuthMode authMode);

        #endregion

        #region user
        /// <summary>
        /// 
        /// </summary>
        /// <param name="authCode"></param>
        /// <returns></returns>
        Task<SessionResponse> GetSessionAsync(string authCode);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="authCode"></param>
        /// <returns></returns>
        Task<UserInfo> GetUserInfoAsync(string authCode);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="refreshToken"></param>
        /// <returns></returns>
        Task<UserInfo> GetUserInfoByRefreshTokenAsync(string refreshToken);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="unionid"></param>
        /// <returns></returns>
        Task<string> GetUserIdAsync(string unionid);
        #endregion

        #region user token
        /// <summary>
        /// 
        /// </summary>
        /// <param name="authCode"></param>
        /// <returns></returns>
        Task<string> CreateUserTokenAsync(string authCode);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="refreshToken"></param>
        /// <returns></returns>
        Task<string> RefreshUserTokenAsync(string refreshToken);

        #endregion
    }
}
